const svc = require('../util/service'),
log = require('../util/log'),
locationDao = require('../dao/locationDao');

module.exports = (req, res) => {
	svc.handlePost(req, res, (obj, resolve) => {
		if (!obj.latitude) {
			resolve({
				result: -1,
				msg: '缺少latitude'
			})
			return
		}
		if (!obj.longitude) {
			resolve({
				result: -1,
				msg: '缺少longitude'
			})
			return
		}
		obj.update_time = new Date();
		locationDao.upsert(obj, () => {
			resolve({
				result: 1
			})
		})
	})
}
